<?php

    session_start ();
    include 'function.php';
    display_header();
    if (isset($_SESSION['login']) && isset($_SESSION['mdp'])) {
    
    include 'include/Data.php';
    $req = mysql_query('SELECT Id_machine, Nom_machine, Started FROM machine_virtuel WHERE Id_machine = "'.$_GET['VM'].'"');
    $ligne = mysql_fetch_assoc($req);
    $nom = $ligne[Nom_machine];

    echo exec ('VBoxManage controlvm "'.$nom.'" poweroff');

    $req2 = "UPDATE machine_virtuel SET Started=0 WHERE Id_machine='".$_GET['VM']."';";
    $ligne2 = mysql_query($req2,$connexion);

    display_footer(); 
    } else { header("Refresh: 0; URL=index.php"); }
    is_log();

?>
